/*
 *	xcommon.h
 *	  part of the xlibrary by SunDEV (http://sundev.890m.com)
 *
 *	Changelog :
 *	  ##-##-## : First public release
 *
 */

#ifndef _XCOMMON_H
#define _XCOMMON_H

#if defined(ARM9) || defined(ARM7)
 #include <nds.h>
#else
 #include "ndstypes.h"

 #ifdef WIN32
 #define bzero(a, b) memset(a, 0, b)
 #endif
#endif

#ifndef MAX
#define MAX(a, b) ((a)>(b)?(a):(b))
#endif
#ifndef MIN
#define MIN(a, b) ((a)<(b)?(a):(b))
#endif

typedef void (*datahandler)(void *);
typedef int (*datacmp)(void *, void *);

// define
#if defined(XDEBUG)
#   define XASSERT_DEBUG
#endif
#if defined(XDEBUG) || defined(XMALLOC_DEBUG)
#   define XMALLOC_DEBUG_CHECK
#   define XMALLOC_DEBUG_WRITE
#endif

// undefine
#if defined(NO_XASSERT_DEBUG) && defined(XASSERT_DEBUG)
#   undef XASSERT_DEBUG
#endif
#if defined(NO_XMALLOC_DEBUG_CHECK) && defined(XMALLOC_DEBUG_CHECK)
#   undef XMALLOC_DEBUG_CHECK
#endif
#if defined(NO_XMALLOC_DEBUG_WRITE) && defined(XMALLOC_DEBUG_WRITE)
#   undef XMALLOC_DEBUG_WRITE
#endif

#endif 
